#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxLength(vector<int>& arr)
    {
        int max = 1;
        unordered_set<int> s;
        for (int i = 0;i < arr.size();i++)
        {
            for (int j = i;j < arr.size();j++)
            {
                //cout<<arr[j];
                if (s.find(arr[j]) == s.end())
                {
                    //cout<<"! ";
                    s.insert(arr[j]);
                }
                else
                {
                    if (s.size() > max)
                    {
                        max = s.size();
                    }
                    //cout<<s.size()<<" ";
                    s.clear();
                    break;
                }
            }
            //cout<<endl;
        }
        return max;
    }
};